package com.eckey.lab.feign;

import com.eckey.lab.entity.Storage;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @Author: Marinc
 * @CreateTime: 2023-09-24  15:54
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
public class StorageFallbackFactory implements FallbackFactory<StorageFeign> {

    public StorageFeign create(Throwable throwable) {
        return new StorageFeign() {

            public ResponseEntity<Storage> queryById(@PathVariable("id") Integer id) {
                return new ResponseEntity<Storage>(HttpStatus.BAD_REQUEST);
            }

            public ResponseEntity<Storage> add(Storage storage) {
                return new ResponseEntity<Storage>(HttpStatus.BAD_REQUEST);
            }


            public ResponseEntity<Storage> edit(Storage storage) {
                return new ResponseEntity<Storage>(HttpStatus.BAD_REQUEST);
            }


            public ResponseEntity<Boolean> deleteById(Integer id) {
                return new ResponseEntity<Boolean>(HttpStatus.BAD_REQUEST);
            }

            public String deduct(String name, Integer totalPrice) {
                throw new RuntimeException("金额扣减异常");
            }

        };
    }

}
